var p = Object.defineProperty, L = Object.defineProperties;
var k = Object.getOwnPropertyDescriptors;
var s = Object.getOwnPropertySymbols;
var C = Object.prototype.hasOwnProperty, N = Object.prototype.propertyIsEnumerable;
var d = (a, e, t) => e in a ? p(a, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : a[e] = t, c = (a, e) => {
  for (var t in e || (e = {}))
    C.call(e, t) && d(a, t, e[t]);
  if (s)
    for (var t of s(e))
      N.call(e, t) && d(a, t, e[t]);
  return a;
}, r = (a, e) => L(a, k(e));
import { reactive as V, computed as o, toRefs as v } from "vue";
import { c as B } from "../component-87e22bdd.mjs";
import { c as M } from "../props-c0e5b20d.mjs";
/*!
* Vin UI 移动端 Vue3 组件库 v0.2.9 Fri Jun 02 2023 21:01:02 GMT+0800 (中国标准时间)
* (c) 2023 @vingogo.
* Released under the MIT License.
*/
const P = r(c({}, M), {
  modelValue: {
    type: [String, Number],
    default: ""
  },
  maxLength: {
    type: [String, Number],
    default: "9999"
  },
  inputType: {
    type: String,
    default: "text"
  },
  placeholder: {
    type: String,
    default: ""
  },
  clearable: {
    type: Boolean,
    default: !0
  },
  background: {
    type: String,
    default: ""
  },
  inputBackground: {
    type: String,
    default: ""
  }
}), { create: T, translate: F, useVinContext: R } = B("searchbar"), A = T({
  props: P,
  emits: ["change", "update:modelValue", "blur", "focus", "clear", "search"],
  setup(a, { emit: e }) {
    const { getMainClass: t, getMainStyle: g } = R(a), u = V({
      active: !1
    }), i = o(t), m = o(() => g({
      background: a.background
    })), h = o(() => ({
      background: a.inputBackground
    })), f = (l) => {
      let { value: n } = l.detail;
      a.maxLength && n.length > Number(a.maxLength) && (n = n.slice(0, Number(a.maxLength))), e("update:modelValue", n, l), e("change", n, l);
    }, b = (l) => {
      const { value: n } = l.detail;
      u.active = !0, e("focus", n, l);
    }, S = (l) => {
      setTimeout(() => {
        u.active = !1;
      }, 0);
      let { value: n } = l.detail;
      a.maxLength && n.length > Number(a.maxLength) && (n = n.slice(0, Number(a.maxLength))), e("blur", n, l);
    }, x = (l) => {
      e("update:modelValue", "", l), e("change", "", l), e("clear", "");
    }, y = () => {
      e("search", a.modelValue);
    };
    return r(c({}, v(u)), {
      mainClass: i,
      valueChange: f,
      valueFocus: b,
      valueBlur: S,
      handleClear: x,
      handleSubmit: y,
      searchbarStyle: m,
      inputSearchbarStyle: h,
      translate: F
    });
  }
});
export {
  A as default
};
